<?php
	$iii=array();
	$jjj=array();
	$kkk=array();
	$ppp=array();
	
	$lock_list = get_ad_lock_list('lock2');
	$lock_list_size = count($lock_list);
	$n= 0;
	foreach($lock_list as $data)
	{
		$iii[$n]="upfiles/".$data['images3'];
		$jjj[$n]=$data['linkisok'];
		$kkk[$n]=$data['link1'];
		$ppp[$n]=$data['link2'];
		$n=$n+1;
	}
	$sql="select * from ad where `lock2` = '' AND isok=0 and images3!=''   order by id desc ";			
	$result=mysql_query($sql);
	while ($row=mysql_fetch_object($result)){
	$iii[$n]="upfiles/".$row->images3;
	$jjj[$n]=$row->linkisok;
	$kkk[$n]=$row->link1;
	$ppp[$n]=$row->link2;
	$n=$n+1;
	}
	
	if($lock_list_size < $n && $lock_list_size > 0)
	{
		$cards =range(0,$lock_list_size -1 );
		
	   $cards_o=range($lock_list_size,$n-1);
	   shuffle($cards_o);
	   foreach($cards_o as $indexN)
	   {
	   		$cards[] = $indexN;
	   }
	}else{
		$cards=range(0,$n-1);
		shuffle($cards);
	}
	
?>
<div id="ad-s"> 
<?php
for($i=0;$i<=10 && $i < $n;$i++){
?>

<?php    //1
if($jjj[$cards[$i]]==1){
?>
<img   src="<?php echo $iii[$cards[$i]];?>"  border="0" width="190" height="66"/>
<?php }?>

<?php 
if($jjj[$cards[$i]]==2){
?>
<a href="<?php echo $kkk[$cards[$i]];?>" target="_blank">
<img   src="<?php echo $iii[$cards[$i]];?>"  border="0" width="190" height="66"/>
</a>
<?php }?>


<?php 
if($jjj[$cards[$i]]==3){
?>
<a href="http://<?php echo $ppp[$cards[$i]];?>" target="_blank">
<img   src="<?php echo $iii[$cards[$i]];?>"  border="0" width="190" height="66"/>
</a>
<?php }}?>
</div>